package com.watson.classload;

import org.yaml.snakeyaml.Yaml;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Properties;

/**
 * @program: mytest
 * @description: class load test
 * @author: zhangpeng348@jd.com
 * @date: 2018-12-04 17:35
 **/
public class LoadTest {

    public LoadTest() {
        try {
            URL resource3 = LoadTest.class.getClassLoader().getResource("config-src.properties");
            URL resource2 = LoadTest.class.getResource("/config-target.properties");
            InputStream resource = this.getClass().getClassLoader().getResourceAsStream("config-target.properties");
            URL resource1 = this.getClass().getClassLoader().getResource("config.yml");
            Yaml yaml = new Yaml();
            LinkedHashMap map = yaml.load(new FileInputStream(resource1.getFile()));
            Properties properties = new Properties();
            properties.load(resource);
            String property = properties.getProperty("com.watson.mytest.url");
            System.out.println(property);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        LoadTest loadTest = new LoadTest();
    }
}
